CSharpTest.Net
Run(TextReader,String[]) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > Run Method : Run(TextReader,String[]) Method

input
arguments

Glossary Item Box

Runs the process with additional arguments and returns the exit code.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Run( _
   ByVal input As TextReader, _
   ByVal ParamArray arguments() As String _
) As Integer
C# 
public int Run( 
   TextReader input,
   params string[] arguments
)

Parameters

input
arguments

Example

Library/Library.Test/TestProcessRunner.cs

C#Copy Code
using (ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "sort"))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };
    int exitCode = runner.Run(new StringReader("Hello World\r\nWhatever!\r\nA line that goes first."));
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual("A line that goes first.", lines[0]);
    Assert.AreEqual("Hello World", lines[1]);
    Assert.AreEqual("Whatever!", lines[2]);
}
VB.NETCopy Code
Using runner As New ProcessRunner("cmd.exe", "/C", "sort")
    Dim lines As New List(Of String)()
    runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
        lines.Add(e.Data)
    End Function
    Dim exitCode As Integer = runner.Run(New StringReader("Hello World" & vbCr & vbLf & "Whatever!" & vbCr & vbLf & "A line that goes first."))
    Assert.AreEqual(0, exitCode)
    Assert.AreEqual("A line that goes first.", lines(0))
    Assert.AreEqual("Hello World", lines(1))
    Assert.AreEqual("Whatever!", lines(2))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys